From 5a7e9fd9f208f61951106b56ced368e3d2d891ab Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 31 May 2010 21:15:10 +0000 Subject: [PATCH] Better warnings on shape reader from unknown geometries. --- shape.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/shape.c b/shape.c index 9f36e0a97..7e14ecec4 100644 --- a/shape.c +++ b/shape.c @@ -113,6 +113,7 @@ void my_read(void) { int npts; + char *etype = "unknown"; SHPGetInfo(ihandle, &npts, NULL, NULL, NULL); @@ -169,8 +170,8 @@ my_read(void) else { url = NULL; } - - if (shp->nSHPType == SHPT_ARC) { + switch (shp->nSHPType) { + case SHPT_ARC: { int j; route_head *routehead = route_head_alloc(); routehead->rte_name = xstrdup(name); @@ -182,9 +183,10 @@ my_read(void) wpt->altitude = shp->padfZ[j]; route_add_wpt(routehead, wpt); } - } + } + break; - if (shp->nSHPType == SHPT_POINT) { + case SHPT_POINT: wpt = waypt_new(); wpt->latitude = shp->dfYMin; wpt->longitude = shp->dfXMin; @@ -193,7 +195,25 @@ my_read(void) wpt->url = xstrdup(url); } waypt_add(wpt); - } + break; + case SHPT_POLYGON: etype = "polygon"; goto err; + case SHPT_MULTIPOINT: etype = "multipoint"; goto err; + case SHPT_POINTZ: etype = "pointz" ; goto err; + case SHPT_ARCZ: etype = "arcz" ; goto err; + case SHPT_POLYGONZ: etype = "polygonz" ; goto err; + case SHPT_MULTIPOINTZ: etype = "multipointz" ; goto err; + case SHPT_POINTM: etype = "pointm" ; goto err; + case SHPT_ARCM: etype = "arcm" ; goto err; + case SHPT_POLYGONM: etype = "polygonm" ; goto err; + case SHPT_MULTIPOINTM: etype = "multipointm" ; goto err; + case SHPT_MULTIPATCH: etype = "multipatch" ; goto err; + default: + + err: + warning("This file contains shapefile geometry type %s that does not naturally convert\nCustom programming is likely required.\n", + etype); + break; + } SHPDestroyObject(shp); -- 2.30.2